package com.etbsms.domain;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name = "Etbsms_Role")
public class Role implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3936451424413886415L;

//	private int seq_no;
	private String name;
	private String description;
	private boolean enabled;
	//private String login_page;
	private int sort;
//	private Set<Users> users = new HashSet<Users>();
	
	
	@Id 
	@Column(name = "name" ,nullable = false,length = 64)
	@GeneratedValue(generator = "paymentableGenerator")       
	@GenericGenerator(name = "paymentableGenerator", strategy = "assigned")
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@Column(name = "description" ,nullable = false,length = 512)
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	
	@Column(name = "sort" ,nullable = false)
	public int getSort() {
		return sort;
	}
	public void setSort(int sort) {
		this.sort = sort;
	}
	
	@Column(name = "enabled" ,nullable = false)
	public boolean isEnabled() {
		return enabled;
	}
	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}	

	/*
	@Column(name = "login_page" ,nullable = false)
	public String getLogin_page() {
		return login_page;
	}
	public void setLogin_page(String login_page) {
		this.login_page = login_page;
	}
	*/
	
	@Override
	public boolean equals(Object obj) {		
		if(obj == null)
			return false;
		if (!(obj instanceof Role) ) 
			return false;
    Role role = (Role) obj;
    return this.name.equals(role.name);		
	}
	
	@Override
	public int hashCode() {
		int result = 17;
		result = 31 * result + name.hashCode();
		return result;  
	}

//	@ManyToMany
//	@JoinTable(name="Etbsms_User_Role",
//		joinColumns={@JoinColumn(name="role_uuid")},
//		inverseJoinColumns={@JoinColumn(name="user_uuid")})
//	public Set<Users> getUsers() {
//		return users;
//	}
//	public void setUsers(Set<Users> users) {
//		this.users = users;
//	}
}
